package com.chengliang.bbs.entry;

import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 连续签到（连续修炼记录对象）
 * @author: chengliang
 * @create: 2019-07-30 18:14
 */
@Data
public class ContinuityPractice implements Serializable {

    /**
     * 主键
     */
    private Integer continuityPracticeId;

    /**
     * 用户信息
     */
    private User user;

    /**
     * 连续签到天数
     */
    private Integer continuityPracticeDayNumber;

    /**
     * 最后签到时间
     */
    private LocalDateTime continuityPracticeLastTime;

    /**
     * 今日是否签到
     */
    private boolean practiced;

    /**
     * 未签到页面显示加一天的经验值
     * @return
     */
    public Integer getExperience(){
        //如果是已签到则返回前一天的获取经验值
        return Experience.getExperienceValue(!practiced?continuityPracticeDayNumber+1:continuityPracticeDayNumber);
    }

    /**
     * 获取今日获取的经验
     * @return
     */
    public int getNowDayExperience(){
        return Experience.getExperienceValue(continuityPracticeDayNumber);
    }

}
